<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class Net::HTTPGenericRequest - net: Ruby Standard Library Documentation</title>


<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<script src="../js/jquery-3.2.0.min.js"></script>

<script src="../js/vue.min.js"></script>
<script src="../js/js.cookie.min.js"></script>

<link href="../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../css/rdoc.css" rel="stylesheet">
<link href="../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
  var darkModeCsseHref = "../css/rdoc-dm.css"
  var defaultModeCssHref = "../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">Object
</div>

        
<div id="includes-section" class="nav-section">
  <h3>Included Modules</h3>

  <ul class="link-list">
    <li><a class="include" href="HTTPHeader.html">Net::HTTPHeader</a>
  </ul>
</div>

        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-i-body-3D">#body=</a>
    <li ><a href="#method-i-body_stream-3D">#body_stream=</a>
    <li ><a href="#method-i-encode_multipart_form_data">#encode_multipart_form_data</a>
    <li ><a href="#method-i-flush_buffer">#flush_buffer</a>
    <li ><a href="#method-i-inspect">#inspect</a>
    <li ><a href="#method-i-quote_string">#quote_string</a>
    <li ><a href="#method-i-request_body_permitted-3F">#request_body_permitted?</a>
    <li ><a href="#method-i-response_body_permitted-3F">#response_body_permitted?</a>
    <li ><a href="#method-i-send_request_with_body">#send_request_with_body</a>
    <li ><a href="#method-i-send_request_with_body_data">#send_request_with_body_data</a>
    <li ><a href="#method-i-send_request_with_body_stream">#send_request_with_body_stream</a>
    <li ><a href="#method-i-supply_default_content_type">#supply_default_content_type</a>
    <li ><a href="#method-i-wait_for_continue">#wait_for_continue</a>
    <li ><a href="#method-i-write_header">#write_header</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-Net::HTTPGenericRequest">
    <h1 id="class-Net::HTTPGenericRequest" class="class">
      class Net::HTTPGenericRequest
    </h1>

    <section class="description">
    
<p>HTTPGenericRequest is the parent of the <a href="HTTPRequest.html"><code>Net::HTTPRequest</code></a> class.</p>

<p>Do not use this directly; instead, use a subclass of <a href="HTTPRequest.html"><code>Net::HTTPRequest</code></a>.</p>

<h2 id="class-Net::HTTPGenericRequest-label-About+the+Examples">About the Examples<span><a href="#class-Net::HTTPGenericRequest-label-About+the+Examples">&para;</a> <a href="#top">&uarr;</a></span></h2>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">



        <section class="attribute-method-details" class="method-section">
        <header>
        <h3>Attributes</h3>
        </header>

          <div id="attribute-i-body" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">body</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>Returns the string body for the request, or <code>nil</code> if there is none:</p>

<pre class="ruby"><span class="ruby-identifier">req</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Post</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">uri</span>)
<span class="ruby-identifier">req</span>.<span class="ruby-identifier">body</span> <span class="ruby-comment"># =&gt; nil</span>
<span class="ruby-identifier">req</span>.<span class="ruby-identifier">body</span> = <span class="ruby-string">&#39;{&quot;title&quot;: &quot;foo&quot;,&quot;body&quot;: &quot;bar&quot;,&quot;userId&quot;: 1}&#39;</span>
<span class="ruby-identifier">req</span>.<span class="ruby-identifier">body</span> <span class="ruby-comment"># =&gt; &quot;{\&quot;title\&quot;: \&quot;foo\&quot;,\&quot;body\&quot;: \&quot;bar\&quot;,\&quot;userId\&quot;: 1}&quot;</span>
</pre>
              </div>
            </div>
          <div id="attribute-i-body_stream" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">body_stream</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>Returns the body stream object for the request, or <code>nil</code> if there is none:</p>

<pre class="ruby"><span class="ruby-identifier">req</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Post</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">uri</span>)          <span class="ruby-comment"># =&gt; #&lt;Net::HTTP::Post POST&gt;</span>
<span class="ruby-identifier">req</span>.<span class="ruby-identifier">body_stream</span>                         <span class="ruby-comment"># =&gt; nil</span>
<span class="ruby-identifier">require</span> <span class="ruby-string">&#39;stringio&#39;</span>
<span class="ruby-identifier">req</span>.<span class="ruby-identifier">body_stream</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;xyzzy&#39;</span>) <span class="ruby-comment"># =&gt; #&lt;StringIO:0x0000027d1e5affa8&gt;</span>
<span class="ruby-identifier">req</span>.<span class="ruby-identifier">body_stream</span>                         <span class="ruby-comment"># =&gt; #&lt;StringIO:0x0000027d1e5affa8&gt;</span>
</pre>
              </div>
            </div>
          <div id="attribute-i-decode_content" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">decode_content</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>Returns <code>false</code> if the request’s header <code>&#39;Accept-Encoding&#39;</code> has been set manually or deleted (indicating that the user intends to handle encoding in the response), <code>true</code> otherwise:</p>

<pre class="ruby"><span class="ruby-identifier">req</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Get</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">uri</span>) <span class="ruby-comment"># =&gt; #&lt;Net::HTTP::Get GET&gt;</span>
<span class="ruby-identifier">req</span>[<span class="ruby-string">&#39;Accept-Encoding&#39;</span>]        <span class="ruby-comment"># =&gt; &quot;gzip;q=1.0,deflate;q=0.6,identity;q=0.3&quot;</span>
<span class="ruby-identifier">req</span>.<span class="ruby-identifier">decode_content</span>            <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-identifier">req</span>[<span class="ruby-string">&#39;Accept-Encoding&#39;</span>] = <span class="ruby-string">&#39;foo&#39;</span>
<span class="ruby-identifier">req</span>.<span class="ruby-identifier">decode_content</span>            <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-identifier">req</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&#39;Accept-Encoding&#39;</span>)
<span class="ruby-identifier">req</span>.<span class="ruby-identifier">decode_content</span>            <span class="ruby-comment"># =&gt; false</span>
</pre>
              </div>
            </div>
          <div id="attribute-i-method" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">method</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>Returns the string method name for the request:</p>

<pre class="ruby"><span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Get</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">uri</span>).<span class="ruby-identifier">method</span>  <span class="ruby-comment"># =&gt; &quot;GET&quot;</span>
<span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Post</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">uri</span>).<span class="ruby-identifier">method</span> <span class="ruby-comment"># =&gt; &quot;POST&quot;</span>
</pre>
              </div>
            </div>
          <div id="attribute-i-path" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">path</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>Returns the string path for the request:</p>

<pre class="ruby"><span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Get</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">uri</span>).<span class="ruby-identifier">path</span> <span class="ruby-comment"># =&gt; &quot;/&quot;</span>
<span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Post</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;example.com&#39;</span>).<span class="ruby-identifier">path</span> <span class="ruby-comment"># =&gt; &quot;example.com&quot;</span>
</pre>
              </div>
            </div>
          <div id="attribute-i-uri" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">uri</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>Returns the URI object for the request, or <code>nil</code> if none:</p>

<pre class="ruby"><span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Get</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">uri</span>).<span class="ruby-identifier">uri</span>
<span class="ruby-comment"># =&gt; #&lt;URI::HTTPS https://jsonplaceholder.typicode.com/&gt;</span>
<span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Get</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;example.com&#39;</span>).<span class="ruby-identifier">uri</span> <span class="ruby-comment"># =&gt; nil</span>
</pre>
              </div>
            </div>
            </section>


                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-body-3D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">body=</span><span
                                class="method-args">(str)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sets the body for the request:</p>

<pre class="ruby"><span class="ruby-identifier">req</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Post</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">uri</span>)
<span class="ruby-identifier">req</span>.<span class="ruby-identifier">body</span> <span class="ruby-comment"># =&gt; nil</span>
<span class="ruby-identifier">req</span>.<span class="ruby-identifier">body</span> = <span class="ruby-string">&#39;{&quot;title&quot;: &quot;foo&quot;,&quot;body&quot;: &quot;bar&quot;,&quot;userId&quot;: 1}&#39;</span>
<span class="ruby-identifier">req</span>.<span class="ruby-identifier">body</span> <span class="ruby-comment"># =&gt; &quot;{\&quot;title\&quot;: \&quot;foo\&quot;,\&quot;body\&quot;: \&quot;bar\&quot;,\&quot;userId\&quot;: 1}&quot;</span>
</pre>

                              <div class="method-source-code" id="body-3D-source">
            <pre><span class="ruby-comment"># File net/http/generic_request.rb, line 154</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">body=</span>(<span class="ruby-identifier">str</span>)
  <span class="ruby-ivar">@body</span> = <span class="ruby-identifier">str</span>
  <span class="ruby-ivar">@body_stream</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@body_data</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">str</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-body_stream-3D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">body_stream=</span><span
                                class="method-args">(input)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sets the body stream for the request:</p>

<pre class="ruby"><span class="ruby-identifier">req</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Post</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">uri</span>)          <span class="ruby-comment"># =&gt; #&lt;Net::HTTP::Post POST&gt;</span>
<span class="ruby-identifier">req</span>.<span class="ruby-identifier">body_stream</span>                         <span class="ruby-comment"># =&gt; nil</span>
<span class="ruby-identifier">require</span> <span class="ruby-string">&#39;stringio&#39;</span>
<span class="ruby-identifier">req</span>.<span class="ruby-identifier">body_stream</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;xyzzy&#39;</span>) <span class="ruby-comment"># =&gt; #&lt;StringIO:0x0000027d1e5affa8&gt;</span>
<span class="ruby-identifier">req</span>.<span class="ruby-identifier">body_stream</span>                         <span class="ruby-comment"># =&gt; #&lt;StringIO:0x0000027d1e5affa8&gt;</span>
</pre>

                              <div class="method-source-code" id="body_stream-3D-source">
            <pre><span class="ruby-comment"># File net/http/generic_request.rb, line 179</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">body_stream=</span>(<span class="ruby-identifier">input</span>)
  <span class="ruby-ivar">@body</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@body_stream</span> = <span class="ruby-identifier">input</span>
  <span class="ruby-ivar">@body_data</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">input</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-inspect" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">inspect</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a string representation of the request:</p>

<pre class="ruby"><span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Post</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">uri</span>).<span class="ruby-identifier">inspect</span> <span class="ruby-comment"># =&gt; &quot;#&lt;Net::HTTP::Post POST&gt;&quot;</span>
</pre>

                              <div class="method-source-code" id="inspect-source">
            <pre><span class="ruby-comment"># File net/http/generic_request.rb, line 101</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">inspect</span>
  <span class="ruby-node">&quot;\#&lt;#{self.class} #{@method}&gt;&quot;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-request_body_permitted-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">request_body_permitted?</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns whether the request may have a body:</p>

<pre class="ruby"><span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Post</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">uri</span>).<span class="ruby-identifier">request_body_permitted?</span> <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Get</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">uri</span>).<span class="ruby-identifier">request_body_permitted?</span>  <span class="ruby-comment"># =&gt; false</span>
</pre>

                              <div class="method-source-code" id="request_body_permitted-3F-source">
            <pre><span class="ruby-comment"># File net/http/generic_request.rb, line 120</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">request_body_permitted?</span>
  <span class="ruby-ivar">@request_has_body</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-response_body_permitted-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">response_body_permitted?</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns whether the response may have a body:</p>

<pre class="ruby"><span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Post</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">uri</span>).<span class="ruby-identifier">response_body_permitted?</span> <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Head</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">uri</span>).<span class="ruby-identifier">response_body_permitted?</span> <span class="ruby-comment"># =&gt; false</span>
</pre>

                              <div class="method-source-code" id="response_body_permitted-3F-source">
            <pre><span class="ruby-comment"># File net/http/generic_request.rb, line 129</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">response_body_permitted?</span>
  <span class="ruby-ivar">@response_has_body</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="private-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Private Instance Methods</h3>
                </header>

                  <div id="method-i-encode_multipart_form_data" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">encode_multipart_form_data</span><span
                                class="method-args">(out, params, opt)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="encode_multipart_form_data-source">
            <pre><span class="ruby-comment"># File net/http/generic_request.rb, line 312</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">encode_multipart_form_data</span>(<span class="ruby-identifier">out</span>, <span class="ruby-identifier">params</span>, <span class="ruby-identifier">opt</span>)
  <span class="ruby-identifier">charset</span> = <span class="ruby-identifier">opt</span>[<span class="ruby-value">:charset</span>]
  <span class="ruby-identifier">boundary</span> = <span class="ruby-identifier">opt</span>[<span class="ruby-value">:boundary</span>]
  <span class="ruby-identifier">require</span> <span class="ruby-string">&#39;securerandom&#39;</span> <span class="ruby-keyword">unless</span> <span class="ruby-keyword">defined?</span>(<span class="ruby-constant">SecureRandom</span>)
  <span class="ruby-identifier">boundary</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">SecureRandom</span>.<span class="ruby-identifier">urlsafe_base64</span>(<span class="ruby-value">40</span>)
  <span class="ruby-identifier">chunked_p</span> = <span class="ruby-identifier">chunked?</span>

  <span class="ruby-identifier">buf</span> = <span class="ruby-string">+&#39;&#39;</span>
  <span class="ruby-identifier">params</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">h</span>={}<span class="ruby-operator">|</span>
    <span class="ruby-identifier">key</span> = <span class="ruby-identifier">quote_string</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">charset</span>)
    <span class="ruby-identifier">filename</span> =
      <span class="ruby-identifier">h</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value">:filename</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">h</span>[<span class="ruby-value">:filename</span>] <span class="ruby-operator">:</span>
      <span class="ruby-identifier">value</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:to_path</span>) <span class="ruby-operator">?</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_path</span>) <span class="ruby-operator">:</span>
      <span class="ruby-keyword">nil</span>

    <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;--#{boundary}\r\n&quot;</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">filename</span>
      <span class="ruby-identifier">filename</span> = <span class="ruby-identifier">quote_string</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">charset</span>)
      <span class="ruby-identifier">type</span> = <span class="ruby-identifier">h</span>[<span class="ruby-value">:content_type</span>] <span class="ruby-operator">||</span> <span class="ruby-string">&#39;application/octet-stream&#39;</span>
      <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;Content-Disposition: form-data; &quot;</span> \
        <span class="ruby-node">&quot;name=\&quot;#{key}\&quot;; filename=\&quot;#{filename}\&quot;\r\n&quot;</span> \
        <span class="ruby-node">&quot;Content-Type: #{type}\r\n\r\n&quot;</span>
      <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">out</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:write</span>) <span class="ruby-operator">||</span> <span class="ruby-operator">!</span><span class="ruby-identifier">value</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:read</span>)
        <span class="ruby-comment"># if +out+ is not an IO or +value+ is not an IO</span>
        <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> (<span class="ruby-identifier">value</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:read</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">read</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">value</span>)
      <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:size</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">chunked_p</span>
        <span class="ruby-comment"># if +out+ is an IO and +value+ is a File, use IO.copy_stream</span>
        <span class="ruby-identifier">flush_buffer</span>(<span class="ruby-identifier">out</span>, <span class="ruby-identifier">buf</span>, <span class="ruby-identifier">chunked_p</span>)
        <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;%x\r\n&quot;</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">size</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">chunked_p</span>
        <span class="ruby-constant">IO</span>.<span class="ruby-identifier">copy_stream</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">out</span>)
        <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;\r\n&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">chunked_p</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-comment"># +out+ is an IO, and +value+ is not a File but an IO</span>
        <span class="ruby-identifier">flush_buffer</span>(<span class="ruby-identifier">out</span>, <span class="ruby-identifier">buf</span>, <span class="ruby-identifier">chunked_p</span>)
        <span class="ruby-value">1</span> <span class="ruby-keyword">while</span> <span class="ruby-identifier">flush_buffer</span>(<span class="ruby-identifier">out</span>, <span class="ruby-identifier">value</span>.<span class="ruby-identifier">read</span>(<span class="ruby-value">4096</span>), <span class="ruby-identifier">chunked_p</span>)
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-comment"># non-file field:</span>
      <span class="ruby-comment">#   HTML5 says, &quot;The parts of the generated multipart/form-data</span>
      <span class="ruby-comment">#   resource that correspond to non-file fields must not have a</span>
      <span class="ruby-comment">#   Content-Type header specified.&quot;</span>
      <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;Content-Disposition: form-data; name=\&quot;#{key}\&quot;\r\n\r\n&quot;</span>
      <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> (<span class="ruby-identifier">value</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:read</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">read</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">value</span>)
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;\r\n&quot;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;--#{boundary}--\r\n&quot;</span>
  <span class="ruby-identifier">flush_buffer</span>(<span class="ruby-identifier">out</span>, <span class="ruby-identifier">buf</span>, <span class="ruby-identifier">chunked_p</span>)
  <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;0\r\n\r\n&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">chunked_p</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-flush_buffer" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">flush_buffer</span><span
                                class="method-args">(out, buf, chunked_p)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="flush_buffer-source">
            <pre><span class="ruby-comment"># File net/http/generic_request.rb, line 368</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">flush_buffer</span>(<span class="ruby-identifier">out</span>, <span class="ruby-identifier">buf</span>, <span class="ruby-identifier">chunked_p</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">buf</span>
  <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;%x\r\n&quot;</span><span class="ruby-operator">%</span><span class="ruby-identifier">buf</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">chunked_p</span>
  <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">buf</span>
  <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;\r\n&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">chunked_p</span>
  <span class="ruby-identifier">buf</span>.<span class="ruby-identifier">clear</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-quote_string" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">quote_string</span><span
                                class="method-args">(str, charset)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="quote_string-source">
            <pre><span class="ruby-comment"># File net/http/generic_request.rb, line 363</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">quote_string</span>(<span class="ruby-identifier">str</span>, <span class="ruby-identifier">charset</span>)
  <span class="ruby-identifier">str</span> = <span class="ruby-identifier">str</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-identifier">charset</span>, <span class="ruby-value">fallback:</span><span class="ruby-operator">-&gt;</span>(<span class="ruby-identifier">c</span>){<span class="ruby-string">&#39;&amp;#%d;&#39;</span><span class="ruby-operator">%</span><span class="ruby-identifier">c</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-string">&quot;UTF-8&quot;</span>).<span class="ruby-identifier">ord</span>}) <span class="ruby-keyword">if</span> <span class="ruby-identifier">charset</span>
  <span class="ruby-identifier">str</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/[\\&quot;]/</span>, <span class="ruby-string">&#39;\\\\\&amp;&#39;</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-send_request_with_body" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">send_request_with_body</span><span
                                class="method-args">(sock, ver, path, body)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="send_request_with_body-source">
            <pre><span class="ruby-comment"># File net/http/generic_request.rb, line 260</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">send_request_with_body</span>(<span class="ruby-identifier">sock</span>, <span class="ruby-identifier">ver</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">body</span>)
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">content_length</span> = <span class="ruby-identifier">body</span>.<span class="ruby-identifier">bytesize</span>
  <span class="ruby-identifier">delete</span> <span class="ruby-string">&#39;Transfer-Encoding&#39;</span>
  <span class="ruby-identifier">supply_default_content_type</span>
  <span class="ruby-identifier">write_header</span> <span class="ruby-identifier">sock</span>, <span class="ruby-identifier">ver</span>, <span class="ruby-identifier">path</span>
  <span class="ruby-identifier">wait_for_continue</span> <span class="ruby-identifier">sock</span>, <span class="ruby-identifier">ver</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">sock</span>.<span class="ruby-identifier">continue_timeout</span>
  <span class="ruby-identifier">sock</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">body</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-send_request_with_body_data" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">send_request_with_body_data</span><span
                                class="method-args">(sock, ver, path, params)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="send_request_with_body_data-source">
            <pre><span class="ruby-comment"># File net/http/generic_request.rb, line 286</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">send_request_with_body_data</span>(<span class="ruby-identifier">sock</span>, <span class="ruby-identifier">ver</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">params</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-regexp">/\Amultipart\/form-data\z/i</span> <span class="ruby-operator">!~</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">content_type</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">content_type</span> = <span class="ruby-string">&#39;application/x-www-form-urlencoded&#39;</span>
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">send_request_with_body</span>(<span class="ruby-identifier">sock</span>, <span class="ruby-identifier">ver</span>, <span class="ruby-identifier">path</span>, <span class="ruby-constant">URI</span>.<span class="ruby-identifier">encode_www_form</span>(<span class="ruby-identifier">params</span>))
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">opt</span> = <span class="ruby-ivar">@form_option</span>.<span class="ruby-identifier">dup</span>
  <span class="ruby-identifier">require</span> <span class="ruby-string">&#39;securerandom&#39;</span> <span class="ruby-keyword">unless</span> <span class="ruby-keyword">defined?</span>(<span class="ruby-constant">SecureRandom</span>)
  <span class="ruby-identifier">opt</span>[<span class="ruby-value">:boundary</span>] <span class="ruby-operator">||=</span> <span class="ruby-constant">SecureRandom</span>.<span class="ruby-identifier">urlsafe_base64</span>(<span class="ruby-value">40</span>)
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">set_content_type</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">content_type</span>, <span class="ruby-value">boundary:</span> <span class="ruby-identifier">opt</span>[<span class="ruby-value">:boundary</span>])
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">chunked?</span>
    <span class="ruby-identifier">write_header</span> <span class="ruby-identifier">sock</span>, <span class="ruby-identifier">ver</span>, <span class="ruby-identifier">path</span>
    <span class="ruby-identifier">encode_multipart_form_data</span>(<span class="ruby-identifier">sock</span>, <span class="ruby-identifier">params</span>, <span class="ruby-identifier">opt</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">require</span> <span class="ruby-string">&#39;tempfile&#39;</span>
    <span class="ruby-identifier">file</span> = <span class="ruby-constant">Tempfile</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;multipart&#39;</span>)
    <span class="ruby-identifier">file</span>.<span class="ruby-identifier">binmode</span>
    <span class="ruby-identifier">encode_multipart_form_data</span>(<span class="ruby-identifier">file</span>, <span class="ruby-identifier">params</span>, <span class="ruby-identifier">opt</span>)
    <span class="ruby-identifier">file</span>.<span class="ruby-identifier">rewind</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">content_length</span> = <span class="ruby-identifier">file</span>.<span class="ruby-identifier">size</span>
    <span class="ruby-identifier">write_header</span> <span class="ruby-identifier">sock</span>, <span class="ruby-identifier">ver</span>, <span class="ruby-identifier">path</span>
    <span class="ruby-constant">IO</span>.<span class="ruby-identifier">copy_stream</span>(<span class="ruby-identifier">file</span>, <span class="ruby-identifier">sock</span>)
    <span class="ruby-identifier">file</span>.<span class="ruby-identifier">close</span>(<span class="ruby-keyword">true</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-send_request_with_body_stream" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">send_request_with_body_stream</span><span
                                class="method-args">(sock, ver, path, f)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="send_request_with_body_stream-source">
            <pre><span class="ruby-comment"># File net/http/generic_request.rb, line 269</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">send_request_with_body_stream</span>(<span class="ruby-identifier">sock</span>, <span class="ruby-identifier">ver</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">f</span>)
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">content_length</span>() <span class="ruby-keyword">or</span> <span class="ruby-identifier">chunked?</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>,
        <span class="ruby-string">&quot;Content-Length not given and Transfer-Encoding is not `chunked&#39;&quot;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">supply_default_content_type</span>
  <span class="ruby-identifier">write_header</span> <span class="ruby-identifier">sock</span>, <span class="ruby-identifier">ver</span>, <span class="ruby-identifier">path</span>
  <span class="ruby-identifier">wait_for_continue</span> <span class="ruby-identifier">sock</span>, <span class="ruby-identifier">ver</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">sock</span>.<span class="ruby-identifier">continue_timeout</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">chunked?</span>
    <span class="ruby-identifier">chunker</span> = <span class="ruby-constant">Chunker</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">sock</span>)
    <span class="ruby-constant">IO</span>.<span class="ruby-identifier">copy_stream</span>(<span class="ruby-identifier">f</span>, <span class="ruby-identifier">chunker</span>)
    <span class="ruby-identifier">chunker</span>.<span class="ruby-identifier">finish</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-constant">IO</span>.<span class="ruby-identifier">copy_stream</span>(<span class="ruby-identifier">f</span>, <span class="ruby-identifier">sock</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-supply_default_content_type" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">supply_default_content_type</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="supply_default_content_type-source">
            <pre><span class="ruby-comment"># File net/http/generic_request.rb, line 376</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">supply_default_content_type</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">content_type</span>()
  <span class="ruby-identifier">warn</span> <span class="ruby-string">&#39;net/http: Content-Type did not set; using application/x-www-form-urlencoded&#39;</span>, <span class="ruby-value">uplevel:</span> <span class="ruby-value">1</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">$VERBOSE</span>
  <span class="ruby-identifier">set_content_type</span> <span class="ruby-string">&#39;application/x-www-form-urlencoded&#39;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-wait_for_continue" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">wait_for_continue</span><span
                                class="method-args">(sock, ver)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Waits up to the continue timeout for a response from the server provided we’re speaking HTTP 1.1 and are expecting a 100-continue response.</p>

                              <div class="method-source-code" id="wait_for_continue-source">
            <pre><span class="ruby-comment"># File net/http/generic_request.rb, line 386</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">wait_for_continue</span>(<span class="ruby-identifier">sock</span>, <span class="ruby-identifier">ver</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">ver</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-string">&#39;1.1&#39;</span> <span class="ruby-keyword">and</span> <span class="ruby-ivar">@header</span>[<span class="ruby-string">&#39;expect&#39;</span>] <span class="ruby-keyword">and</span>
      <span class="ruby-ivar">@header</span>[<span class="ruby-string">&#39;expect&#39;</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;100-continue&#39;</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">sock</span>.<span class="ruby-identifier">io</span>.<span class="ruby-identifier">to_io</span>.<span class="ruby-identifier">wait_readable</span>(<span class="ruby-identifier">sock</span>.<span class="ruby-identifier">continue_timeout</span>)
      <span class="ruby-identifier">res</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTPResponse</span>.<span class="ruby-identifier">read_new</span>(<span class="ruby-identifier">sock</span>)
      <span class="ruby-keyword">unless</span> <span class="ruby-identifier">res</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTPContinue</span>)
        <span class="ruby-identifier">res</span>.<span class="ruby-identifier">decode_content</span> = <span class="ruby-ivar">@decode_content</span>
        <span class="ruby-identifier">throw</span> <span class="ruby-value">:response</span>, <span class="ruby-identifier">res</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-write_header" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">write_header</span><span
                                class="method-args">(sock, ver, path)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="write_header-source">
            <pre><span class="ruby-comment"># File net/http/generic_request.rb, line 399</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">write_header</span>(<span class="ruby-identifier">sock</span>, <span class="ruby-identifier">ver</span>, <span class="ruby-identifier">path</span>)
  <span class="ruby-identifier">reqline</span> = <span class="ruby-node">&quot;#{@method} #{path} HTTP/#{ver}&quot;</span>
  <span class="ruby-keyword">if</span> <span class="ruby-regexp">/[\r\n]/</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">reqline</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">&quot;A Request-Line must not contain CR or LF&quot;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">buf</span> = <span class="ruby-string">+&#39;&#39;</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">reqline</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;\r\n&quot;</span>
  <span class="ruby-identifier">each_capitalized</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;#{k}: #{v}\r\n&quot;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;\r\n&quot;</span>
  <span class="ruby-identifier">sock</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">buf</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>. </p><p><a href="https://jamesbritt.bandcamp.com/">Hack your world.  Feed your head.  Live curious</a>.</p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

